FROM alpine:edge
MAINTAINER izuolan <i@zuolan.me> 

ENV JAVA_VERSION_MAJOR=8 \ 
JAVA_VERSION_MINOR=161 \ 
JAVA_VERSION_BUILD=12 \ 
JAVA_PACKAGE=server-jre \ 
GLIBC_PKG_VERSION=2.27-r0 \ 
LANG=en_US.UTF8 

WORKDIR /tmp 

RUN apk add --no-cache --update-cache curl ca-certificates bash && \ 
    curl -Lo /etc/apk/keys/andyshinn.rsa.pub "https://github.com/andyshinn/alpine-pkg-glibc/releases/download/${GLIBC_PKG_VERSION}/andyshinn.rsa.pub" && \ 
    curl -Lo glibc-${GLIBC_PKG_VERSION}.apk "https://github.com/andyshinn/alpine-pkg-glibc/releases/download/${GLIBC_PKG_VERSION}/glibc-${GLIBC_PKG_VERSION}.apk" && \ 
    curl -Lo glibc-bin-${GLIBC_PKG_VERSION}.apk "https://github.com/andyshinn/alpine-pkg-glibc/releases/download/${GLIBC_PKG_VERSION}/glibc-bin-${GLIBC_PKG_VERSION}.apk" && \ curl -Lo glibc-i18n-${GLIBC_PKG_VERSION}.apk "https://github.com/andyshinn/alpine-pkg-glibc/releases/download/${GLIBC_PKG_VERSION}/glibc-i18n-${GLIBC_PKG_VERSION}.apk" && \ 
    apk add glibc-${GLIBC_PKG_VERSION}.apk glibc-bin-${GLIBC_PKG_VERSION}.apk glibc-i18n-${GLIBC_PKG_VERSION}.apk && \
    curl -jksSLH "Cookie: oraclelicense=accept-securebackup-cookie" \ "http://download.oracle.com/otn-pub/java/jdk/${JAVA_VERSION_MAJOR}u${JAVA_VERSION_MINOR}-b${JAVA_VERSION_BUILD}/${JAVA_PACKAGE}-${JAVA_VERSION_MAJOR}u${JAVA_VERSION_MINOR}-linux-x64.tar.gz" | gunzip -c - | tar -xf - && \ 
    apk del curl ca-certificates && \
    mv jdk1.${JAVA_VERSION_MAJOR}.0_${JAVA_VERSION_MINOR}/jre /jre && \
    rm /jre/bin/jjs && \
    rm /jre/bin/keytool && \ 
    rm /jre/bin/orbd && \ rm /jre/bin/pack200 && \
    rm /jre/bin/policytool && \
    rm /jre/bin/rmid && \ 
    rm /jre/bin/rmiregistry && \
    rm /jre/bin/servertool && \ 
    rm /jre/bin/tnameserv && \
    rm /jre/bin/unpack200 && \ rm /jre/lib/ext/nashorn.jar && \
    rm /jre/lib/jfr.jar && \ rm -rf /jre/lib/jfr && \
    rm -rf /jre/lib/oblique-fonts && \ 
    rm -rf /tmp/* /var/cache/apk/* && \
    echo 'hosts: files mdns4_minimal [NOTFOUND=return] dns mdns4' >> /etc/nsswitch.conf 

ENV JAVA_HOME=/jre 
ENV PATH=${PATH}:${JAVA_HOME}/bin

